package com.example.dao;

import com.example.entity.Admininfo;
import com.example.entity.TeacherInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 涛某
 * @version 1.0
 * @date 2024/3/21 13:55
 */
@Repository
public interface TeacherInfoDao extends Mapper<TeacherInfo> {
    @Select("select * from teacher where name = #{name} and password = #{password}" )
    TeacherInfo findByNameAndPassowrd(@Param("name") String name, @Param("password") String password);


    @Select("select * from teacher where id = #{id}")
    TeacherInfo FindById(Long id);


    @Update("update teacher set name = #{name},sex=#{sex},age = #{age}, zhicheng = #{zhicheng},zhuanyeid = #{zhuanyeid} where id = #{id}")
    void update(TeacherInfo teacherInfo);

    @Insert("insert into teacher(name,sex,age,zhicheng,zhuanyeid,password) values(#{name},#{sex},#{age},#{zhicheng},#{zhuanyeid},#{password})")
    void add(TeacherInfo teacherInfo);

    @Select("select * from teacher where name = #{name}")
    TeacherInfo FindByName(@Param("name") String name);


    @Select("select * from teacher")
    List<TeacherInfo> findAll();

    @Delete("delete from teacher where id = #{id}")
    void deleteById(Long id);

    @Select("select * from teacher where name like concat('%',#{name},'%')")
    List<TeacherInfo> findByNamePage(@Param("name") String name);
}
